<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title>{$vo.title}</title>
<link rel="stylesheet" type="text/css" href="http://img1.messagehelper.net/static/static100517.css"/>
<script>
var $=function(id){return document.getElementById(id);};
var dataForWeixin={
   appId:"",
   MsgImg:"http://img1.messagehelper.net/images/share_msg.png",
   TLImg:"http://img1.messagehelper.net/images/share.png",
   path:"",
   title:"{$vo.title}",
   desc:"{$vo.title}",
   fakeid:"",
   callback:function(){_$("/servlet/share?kind=app&id=0","","");}
};
</script>
</head>
<body> 

<style>body{background-color:#f0f0f0;}</style>
<div id="mess_title">{$vo.title}</div>
<div id="mess_info">{$vo.ctime|toDate}</div>

    <div id="mess_content">{$vo.desc}</div>


<div id="mess_attch">
此次投票，已收到<span id="vote_counts">{$usercount}</span>票。投票后可见结果
</div>
<div id="attch_list">
  <empty name="itemlist[counts]" >
    <volist name="itemlist" id="item">
       <div class="attch_item" onclick="_vote._select({$item.id})">
          <div><div class="option_title">{$item.title}</div><div class="option_vote"><img id="option_{$item.id}" src="http://img2.messagehelper.net/images/vote_sg_no.png"></div><div class="clear"></div></div>
       </div>
    </volist>
  <else/>
    <volist name="itemlist.list" id="item">
       <div class='attch_item'><div><div class='option_title'>{$item.title}</div><div class='option_info'>{$item.count}票&nbsp;{$item.speed}%</div><div class='clear'></div></div><div><div class='option_green' style='width:{$item.speed}%;'></div><div class='option_gray' style='width:{$item.respeed}%;'></div><div class='clear'></div></div><div class='option_vote'></div></div>
    </volist>
  </empty>
           
</div>
<div>

      
    
  <empty name="itemlist[counts]" >
    <button id="vote_vote" class="button1" onclick="_vote._vote()">投票</button>
  <else/>
  <div class="none" id="test_result" style="display: block;">{$vo.intro}</div>
    <button class="button1" >成功投票</button>
  </empty>

</div>
<div id="mess_share">
   <div id="share_1"><button class="button2" onclick="_system._guide(true)"><img src="http://img1.messagehelper.net/images/icon_msg.png">&nbsp;发送给朋友</button></div>
   <div  id="share_2"><button class="button2" onclick="_system._guide(true)"><img src="http://img1.messagehelper.net/images/icon_timeline.png">&nbsp;分享到朋友圈</button></div>
   <div class="clear"></div>
</div>




<script>

var _vote={
   _sel:"",
   _select:function(id){
      if($("option_"+id).src.indexOf("_yes")!=-1){
         $("option_"+id).src=$("option_"+id).src.replace(/_yes/,"_no");
     this._sel=(","+this._sel+",").replace(","+id+",","");
      }else{
     $("option_"+id).src=$("option_"+id).src.replace(/_no/,"_yes");
         if("sg"=="sg"){
        if(this._sel!=""){$("option_"+this._sel).src=$("option_"+id).src.replace(/_yes/,"_no");}
        this._sel=id.toString();
     }else{
        this._sel+=","+id;
     }
      }
      this._sel=this._sel.replace(/\,{2,}/g,",").replace(/^\,/g,"").replace(/\,$/g,"");
   },
   _vote:function(){
      if(this._sel==""){_system._toast("你没有做出任何选择");return;}
      _$("{:U("Mobile/Plus/join?plusid=$plusid&id=$vo[id]")}","vid={$vo.id}&kind=sg&itemid="+this._sel,"请稍候","_vote._ok");
   },
   _ok:function(json){
      if(json.state=="0"){_system._toast("你的操作有误");return;}
      if(json.state=="1"){_system._toast("你已经投过票了");return;}
      _system._ok("投票成功",function(){
         $("vote_vote").innerHTML="投票成功";
         $("vote_vote").onclick=function(){_system._toast("你已经投过票了");};
         // $("attch_list").innerHTML=json.html;
         // $("vote_counts").innerHTML=json.counts;
     // if($("test_result")){$("test_result").show();}
      });
   }
};

</script>

<div class="none"><img src="http://img2.messagehelper.net/images/vote_sg_yes.png"><img src="http://img2.messagehelper.net/images/vote_mt_yes.png"></div>

<div id="ok"><img src="http://img2.messagehelper.net/images/ok.png"><div id="ok_text"></div></div>
<div id="cover"></div>
<div id="loading"><img src="http://img2.messagehelper.net/images/loading.gif"><div id="loading_text"></div></div>
<div id="guide"><div><img src="http://img2.messagehelper.net/images/guide.png"></div><div id="guide_button"><div class="clear"></div></div><div id="guide_button2"><button class="button2" onclick="_system._guideHide()">取消</button></div></div>
<div id="guide2"><img src="http://img2.messagehelper.net/images/guide2.png"></div>
<div id="guide3"><img src="http://img2.messagehelper.net/images/guide3.png"></div>
<div id="toast"></div>
<script>var _fromCode="http://{$Think.server.SERVER_NAME}{$Think.server.REQUEST_URI}?";</script>
<script type="text/javascript">
  String.prototype.len=function(){return this.replace(/[^\x00-\xff]/g,"aa").length;};
String.prototype.trim=function(){return this.replace(/(^ *)|( *$)/g, "");};
String.prototype.htmlencode=function(){return this.replace(/[<>"']+/g,"");};
String.prototype.encode=function(){return escape(encodeURIComponent(this));};
String.prototype.left=function(length){
  if(this.len()>length){
      var _temp=this;
      _temp=_temp.replace(/([^\x00-\xff])/g,"$1>");
      _temp=_temp.substring(0,length-2)+"..";
      return _temp.replace(/>/g,"");
  }else{
      return this.toString();
  }
};
Element.prototype.show=function(){this.style.display="block";};
Element.prototype.hide=function(){this.style.display="none";};
Element.prototype.center=function(top){
   this.style.left=(_system._scroll().x+_system._zero(_system._client().bw-this.offsetWidth)/2)+"px";
   this.style.top=(top?top:(_system._scroll().y+_system._zero(_system._client().bh-this.offsetHeight)/2))+"px";
};
var _system={
   _client:function(){
      return {w:document.documentElement.scrollWidth,h:document.documentElement.scrollHeight,bw:document.documentElement.clientWidth,bh:document.documentElement.clientHeight};
   },
   _scroll:function(){
      return {x:document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft,y:document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop};
   },
   _cover:function(show){
      if(show){
       $("cover").show();
       $("cover").style.width=(this._client().bw>this._client().w?this._client().bw:this._client().w)+"px";
       $("cover").style.height=(this._client().bh>this._client().h?this._client().bh:this._client().h)+"px";
    }else{
       $("cover").hide();
    }
   },
   _loading:function(text){
      if(text){
         this._cover(true);
         $("loading").show();
     $("loading_text").innerHTML=text;
     $("loading").center();
     window.onresize=function(){_system._cover(true);$("loading").center();};
    }else{
         this._cover(false);
         $("loading").hide();
     window.onresize=null;
    }
   },
   _toast:function(text,fun){
      $("toast").show();
      $("toast").innerHTML=text;
      $("toast").center();
      setTimeout(function(){
       $("toast").hide();
     if(fun){(fun)();}
      },3*1000);
   },
   _ok:function(text,fun){
      $("ok").show();
      $("ok_text").innerHTML=text;
      $("ok").center();
    window.onresize=function(){$("ok").center();};
      setTimeout(function(){
     window.onresize=null;
       $("ok").hide();
         (fun)();
      },2*1000);
   },
   _guide:function(show){
      this._cover(true);
      $("guide").show();
      window.onresize=function(){_system._cover(true);};
    if(show){
     $("cover").onclick=_system._guideHide;
     $("guide_button").hide();$("guide_button2").show();
    }else{
         $("guide_button").show();$("guide_button2").hide();
    }
   },
   _guideHide:function(){
      _system._cover();
      $("guide").hide();
      $("cover").onclick=null;
      window.onresize=null;
   },
   _guide2:function(){
    if(_cookie._get("GUIDE2")!=""){return;}
      this._cover(true);
      $("guide2").show();
      window.onresize=function(){_system._cover(true);};
      setTimeout(function(){
     _system._cover();
         $("guide2").hide();
     $("cover").onclick=null;
     window.onresize=null;
     _cookie._set("GUIDE2","1",60*60*24*30);
    },5*1000);
   },
   _zero:function(n){
      return n<0?0:n;
   },
   _forbidden:function(text){
     //return text.match(/(老市长|薄熙来|薄市长|法轮功)/)!=null;
      return false;
   }
};



(function(){
   var onBridgeReady=function(){
   WeixinJSBridge.on('menu:share:appmessage', function(argv){
      WeixinJSBridge.invoke('sendAppMessage',{
         "appid":dataForWeixin.appId,
         "img_url":dataForWeixin.MsgImg,
         "img_width":"120",
         "img_height":"120",
         "link":_fromCode,
         "desc":"{$vo.title}",
         "title":"{$vo.title}"
      }, function(res){(dataForWeixin.callback)();});
   });
   WeixinJSBridge.on('menu:share:timeline', function(argv){
    (dataForWeixin.callback)();
    WeixinJSBridge.invoke('shareTimeline',{
         "img_url":dataForWeixin.TLImg,
         "img_width":"120",
         "img_height":"120",
         "link":_fromCode,
         "desc":"{$vo.title}",
         "title":"{$vo.title}"
      }, function(res){});
   });
   WeixinJSBridge.on('menu:share:weibo', function(argv){
    WeixinJSBridge.invoke('shareWeibo',{
         "content":dataForWeixin.title,
         "url":_fromCode+dataForWeixin.path
      }, function(res){(dataForWeixin.callback)();});
   });
   WeixinJSBridge.on('menu:share:facebook', function(argv){
    (dataForWeixin.callback)();
    WeixinJSBridge.invoke('shareFB',{
         "img_url":dataForWeixin.TLImg,
         "img_width":"120",
         "img_height":"120",
         "link":_fromCode,
         "desc":"{$vo.title}",
         "title":"{$vo.title}"
      }, function(res){});
   });
};
if(document.addEventListener){
   document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
}else if(document.attachEvent){
   document.attachEvent('WeixinJSBridgeReady'   , onBridgeReady);
   document.attachEvent('onWeixinJSBridgeReady' , onBridgeReady);
}
})();


var _cookie={
  _set:function(name,value,expires){
     if(expires){
      var _end = new Date();
      _end.setTime(_end.getTime()+(expires*1000));
      }
      document.cookie=name+"="+escape(value)+(expires ? ";expires="+_end.toGMTString() : "")+"; path=/";
    },
  _get:function(name){
       var _cookie=document.cookie;
       var _start=_cookie.indexOf(name+"=");
       if(_start!=-1){
          _start+=name.length+1;
          var _end=_cookie.indexOf(";",_start);
          if(_end==-1){_end = _cookie.length;}
          return unescape(_cookie.substring(_start,_end));
        }
        return "";
    }
};
var _$=function(url,parameters,loadingMessage,functionName){
    var request=new XMLHttpRequest();
    if(loadingMessage!=""){_system._loading(loadingMessage);}
    var method="POST";
    if(parameters==""){method="GET";parameters=null;}
    request.open(method,url,true);
    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    request.onreadystatechange=function(){
   if(request.readyState==4){
         if(loadingMessage != ""){_system._loading();}
       if(request.status==200){
        if(functionName){
           try{
            var json = eval("("+ request.responseText+")");
            eval(functionName+"(json)");
                }catch(e){}
        }
       }else{
           if(loadingMessage != ""){_system._toast("发生意外错误，请稍候再试");}
       }
   }
    };
    request.send(parameters);
};
(function(){
  if(document.referrer!=""){
     _system._guide2();
  }
  if(location.href.toString().indexOf("pre=true")!=-1){
    setInterval(function(){
       $("guide3").show();
     setTimeout(function(){
            $("guide3").hide();
     },500);
    },1000);
  }
})();

</script>

</body>
</html>
 